package jp.michi.makimono;

import java.io.File;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.preference.PreferenceManager;

public class Preference {
    public static File getLastVisited(Context context) {
        String lastVisited = PreferenceManager.getDefaultSharedPreferences(context).getString("lastVisited", "/sdcard/");
        File file = new File(lastVisited);
        File parent = file.getParentFile();
        while (parent != null && !file.exists()) {
            file = parent;
            parent = file.getParentFile();
        }
        return file;
    }
    public static void setLastVisited(Context context, String folderName) {
        PreferenceManager.getDefaultSharedPreferences(context).edit().putString("lastVisited", folderName).commit();
    }
    public static int getOrientation(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context).getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
    public static void setOrientation(Context context, int orientation) {
        PreferenceManager.getDefaultSharedPreferences(context).edit().putInt("orientation", orientation).commit();
    }
    //    public static int getHideStatusbar(Context context) {
    //        return PreferenceManager.getDefaultSharedPreferences(context).getInt("hide-statusbar", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    //    }
    //    public static void setOrientation(Context context, int orientation) {
    //        PreferenceManager.getDefaultSharedPreferences(context).edit().putInt("orientation", orientation).commit();
    //    }
}
